<@>layout("/common/default.html"){
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
           <span lay-separator="">/</span>
        <a href="">信息管理</a>
           <span lay-separator="">/</span>
        <a><cite>短信</cite></a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i>
    </a>
</div>
<div class="x-body">
    <div class="layui-row">
        <div class="layui-form layui-col-md12 x-so">
            <input id="phoneNumber" type="text" name="phoneNumber" placeholder="手机号" autocomplete="off" class="layui-input">
            <button class="layui-btn" onclick="doSearch();"><i class="layui-icon">&#xe615;</i></button>
            <button class="layui-btn" onclick="x_admin_show('添加信息','${ctxPath}/information/add',600,400)"><i
                    class="layui-icon"></i>添加
            </button>
        </div>
    </div>
    <div class="layui-row layui-col-space15">
        <table class="layui-table"
               lay-data="{id:'information-list', url:'${ctxPath}/ajax/information/list', page:true,request: {pageName: 'page' ,limitName: 'rows'} }"
               lay-filter="information-list">
            <thead>
            <tr>
                <th lay-data="{field:'index', width:80, templet: '#table-index'}">序号</th>
                <th lay-data="{field:'phoneNumber', width:150}">手机号</th>
                <th lay-data="{field:'content', width:150}">内容</th>
                <th lay-data="{field:'createTimeStr', width:280, sort:true}">创建时间</th>
                <th lay-data="{field:'createUserName', width:200}">创建人</th>
                <th lay-data="{field:'id', toolbar: '#toolbar',fixed:'right',width:200}">操作</th>
            </tr>
            </thead>
        </table>
    </div>

    <script type="text/html" id="toolbar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">详情编辑</a>
        <a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="send" title="发送"> <i class="layui-icon"></i></a>
    </script>

    <script type="text/html" id="role-state">
    </script>

    <script type="text/html" id="table-index">
        {{d.LAY_TABLE_INDEX + 1}}
    </script>
</div>
<script>
    $(function () {
        layui.use('table', function () {
            var table = layui.table;
            table.on('tool(information-list)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                if (layEvent === 'edit') {//编辑
                    x_admin_show('编辑短信', '${ctxPath}/information/edit?id=' + data.id, 600, 400)
                }
                if (layEvent === 'send') {//发送
                    sendContent(data.id,data.phoneNumber,data.content);
                }
            });
        });
    });
    function sendContent(id,phoneNumber,content) {
        $.cajax('${ctxPath}/ajax/information/sendContent',{id:id,phoneNumber:phoneNumber,content,content}, function (r) {
            var code = r.code;
            var msg = r.msg;
            if (code == '1') {
                $.msg(msg, function () {
                }, code);
            } else {
                $.msg(msg, function () {
                }, 2);
            }
        });

    }
    //搜索
    function doSearch() {
        layui.use('table', function () {
            var table = layui.table;
            table.reload('information-list', {
                url: '${ctxPath}/ajax/information/list',
                where: {
                    phoneNumber: $('#phoneNumber').val()
                }//设定异步数据接口的额外参数
            });
        });
    }
</script>
<@>}